package com.example.recyclerviewfenzu.JAC;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;

import com.example.recyclerviewfenzu.R;

import java.util.List;

/**
 * @功能:
 * @Creat 2020/3/14 15:08
 * @User Lmy
 * @Compony JinAnChang
 */
public class RecyclerViewAdapter3 extends RecyclerView.Adapter<RecyclerViewAdapter3.ViewHolder> {
    private Context context;
    private List<DataListBean.DataBean.StateListBean.OtherBean> other;

    public RecyclerViewAdapter3(Context context, List<DataListBean.DataBean.StateListBean.OtherBean> other) {
        this.context = context;
        this.other = other;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.recyclerview3_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvContent.setText(other.get(position).getValue());
        holder.tvName.setText(other.get(position).getName());
    }
    @Override
    public int getItemCount() {
        return other.size();
    }
    class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tvName;
        private TextView tvContent;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_name);
            tvContent = itemView.findViewById(R.id.tv_content);
        }
    }
}
